<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">

    $(document).ready(function() {

        Page.render();
        Page.setStripeTable();

        var theUpdateFileName = "";
        var $btnUpload = $('#btnUpload');
        var datas;
        $btnUpload.bind('click', function() {
            SysUtil.upload($('#form1'), $('#fp'), "system", function(fileName) {
                theUpdateFileName = fileName;
                closeBox();
            }); 
        });

        function update() {
            var isOk = false;
            datas = null;
            SysUtil.showProgress(ProgressTime.UPDATE_PARTIAL, PROMPT.status.updating,
                function() {
                    return datas != null || isOk;
                },
                function() {
				     if(datas == -1 || datas == -2)
					 {
					    AlertUtil.alertMsg(PROMPT.status.updateFalse);
						location.reload();
					  }else {
					   AlertUtil.alertMsg(PROMPT.status.updateSuccess);
						location.href = Page.getUrl(Url.LOGIN);
					 
					 }
                        
                }
            );
           
        }

        $('#btnUpdatePartial').bind('click', function() {
            
            if (theUpdateFileName == "") {
                    AlertUtil.alertMsg(CHECK.required.uploadFile);
                    return false;
            }
            

            Page.postJSON({
                json: {
                    cmd: RequestCmd.UPDATE_PARTIAL, 
                    method: JSONMethod.POST,
                    fileName: theUpdateFileName
                },
                success: function(data) {
                    //console.log("success" + data); 
					datas = data.data;
                },
                fail: function(data) {
                    //console.log("fail" + data);
					datas = data.data;
                }
            });

            update();
        });

    });

</script>

<div class="detail_box" id="child_container">
    <script type="text/template" id="child_template">
        <div class="detail"><%- title.localUpdate %></div>
        <table class="detail" cellspacing="0">
            <tr>
                <th><%- sys.selectUpdateFile %><%- colon %></th>
                <td>
                    <form id="form1" enctype="multipart/form-data" method="post">
                        <input type="file" id="fp" name="fp" value="<%- btn.browse %>" size="40" />
                        <input type="button" id="btnUpload" value="<%- btn.upload %>"/>
                    </form>
                </td>
            </tr>
            <tr>
                <th></th>
                <td><input type="button" id="btnUpdatePartial" value="<%- btn.update %>"/></td>
            </tr>
        </table>
        <div class="detail"  style="display:none;"><%- title.remoteUpdate %></div>
        <form id="remoteForm" enctype="multipart/form-data" method="post"  style="display:none;">
            <table class="detail" cellspacing="0">
                <tr>
                    <th><%- lbl.fotaUrl %><%- colon %></th>
                    <td><!-- FOTA_URL --></td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <input type="button" id="btnUpdate" value="<%- btn.update %>"/>
                    </td>
                </tr>
            </table>
        </form>
    </script>
</div>